{extend name="layout/layout"}
{block name="content"}
<main class="active">
    <div class="head_a1">
        <div class="layui-main">
            <div class="b1">
                <div class="t1">步驟一：活動資訊( 活動主題 )</div>
                <a href="/" class="back_btn"><img src="__ROOT__/public/activity/images/out.png">返回首页</a>
            </div>
        </div>
    </div>
    <div class="main_a">
        <div class="layui-main">
            <div class="active_w c ">
                <p class="text-align-center ft18 mb40 ft-bold">選擇活動主題（最多選擇2個）</p>

                <from class="layui-form ">
                    <div class="content">
                        <div class="active4_b1">
                            <ul class="layui-row layui-col-space20 ul_height a4_ul1 active_ul more activity-theme">
                                {foreach $themeList as $theme}
                                <li class="layui-col-md2 layui-col-xs3" >
                                    <div class="item {if in_array($theme.id,$selected)}active{/if} theme" style="cursor: pointer" data-id="{$theme.id}" >
                                        <div class="img_box" >
                                            <!-- <img class="i1" src="__ROOT__/public/activity/images/a41.png"> -->
                                            {if $theme.thumb} 
                                            <img  class="i1" title="图片" src="{$theme.thumb}"/>
                                            {else /}
                                            <img class="i1" src="__ROOT__/public/activity/images/a41.png">
                                            {/if}
                                      
                                            <!-- <img class="i2" src="__ROOT__/public/activity/images/a42.png"> -->
                                        </div>
                                        <p>{$theme.name}</p>
                                    </div>
                                </li>
                                {/foreach}
                            </ul>
                        </div>
                    </div>
                </from>
                <div class="mt100 d-flex jc-s al-c">
                    <a href="/activity/create/agreement.html" class="last-btn">
                        <img src="__ROOT__/public/activity/images/out1.png">返回上一步
                    </a>
                    <a href="javascript:;" onclick="goNext()">
                        <button class="layui-btn layui-bg-orange next-btn">下一步</button>
                    </a>
                </div>
            </div>

        </div>
    </div>
    <script>
        $(document).ready(function(){
            $(document).on('click', '.active_ul .items', function () {
                
                if ($(this).closest('.active_ul').hasClass('more')) {
                    $(this).toggleClass('active')
                    return;
                }
                $(this).closest('.active_ul').find('.active').removeClass('active');
                $(this).addClass('active')
            })
        })
        function goNext() {
            var selected = [];
            $('.activity-theme .active').each(function (k,elem) {
                selected.push($(elem).data('id'))
            })
            // if(selected.length  > 2) {
            //     return layui.layer.msg('最多選擇2個活動主題');
            // }
            $.quickPost('{:url("/activity/create/theme")}', {theme: selected}).done(res=>{
                location.href = '/activity/create/type.html';
            });
        }
    </script>
</main>

{/block}
